import requests

url = "https://api.seniverse.com/v3/weather/now.json"

params = {
    "key": "xxxxxxxxxxxxxxxxx", # 私钥
    "location": "北京",
    "language": "zh-Hans",
    "unit": "c",
}

# 获取数据
r = requests.get(url, params=params)
# 解析数据
data = r.json()["results"]

address = data[0]["location"]['path']  # 地点
temperature = data[0]['now']["temperature"]  # 温度
text = data[0]['now']["text"]  # 天气情况

# 输出显示
message = address + " \n当前天气：\n" + \
          "温度：" + temperature + "℃" + \
          "\n天气情况：" + text
print(message)

